package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.api.domain.request.ProjectCatalogRequest;
import com.nbsaas.boot.project.data.entity.ProjectCatalog;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;

/**
 * 项目分类请求对象转换成实体对象
 */

public class ProjectCatalogEntityConvert implements Converter<ProjectCatalog, ProjectCatalogRequest> {

    @Override
    public ProjectCatalog convert(ProjectCatalogRequest source) {
        ProjectCatalog result = new ProjectCatalog();
        BeanDataUtils.copyProperties(source, result);
        if (source.getParent() != null) {
            ProjectCatalog parent = new ProjectCatalog();
            parent.setId(source.getParent());
            result.setParent(parent);
        }
        return result;
    }
}

